package b.i.k;

import android.os.Build.VERSION;
import android.os.Bundle;
import android.text.Spanned;
import android.text.style.ClickableSpan;
import android.util.SparseArray;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import b.i.k.y.b;
import b.i.k.y.c;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.WeakHashMap;

/* compiled from: AccessibilityDelegateCompat */
public class a {
    public static final AccessibilityDelegate c = new AccessibilityDelegate();
    public final AccessibilityDelegate a;
    public final AccessibilityDelegate b;

    /* compiled from: AccessibilityDelegateCompat */
    public static final class a extends AccessibilityDelegate {
        public final a a;

        public a(a aVar) {
            this.a = aVar;
        }

        public boolean dispatchPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
            return this.a.a(view, accessibilityEvent);
        }

        public AccessibilityNodeProvider getAccessibilityNodeProvider(View view) {
            c b = this.a.b(view);
            return b != null ? (AccessibilityNodeProvider) b.a : null;
        }

        public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
            this.a.c(view, accessibilityEvent);
        }

        public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfo accessibilityNodeInfo) {
            boolean z;
            boolean z2;
            View view2 = view;
            Class cls = Boolean.class;
            b bVar = new b(accessibilityNodeInfo);
            WeakHashMap weakHashMap = o.a;
            Boolean bool = (Boolean) new p(2131297022, cls, 28).c(view2);
            if (bool == null) {
                z = false;
            } else {
                z = bool.booleanValue();
            }
            int i = VERSION.SDK_INT;
            if (i >= 28) {
                bVar.a.setScreenReaderFocusable(z);
            } else {
                bVar.h(1, z);
            }
            Boolean bool2 = (Boolean) new r(2131297019, cls, 28).c(view2);
            if (bool2 == null) {
                z2 = false;
            } else {
                z2 = bool2.booleanValue();
            }
            if (i >= 28) {
                bVar.a.setHeading(z2);
            } else {
                bVar.h(2, z2);
            }
            CharSequence charSequence = (CharSequence) new q(2131297020, CharSequence.class, 8, 28).c(view2);
            if (i >= 28) {
                bVar.a.setPaneTitle(charSequence);
            } else {
                bVar.a.getExtras().putCharSequence("androidx.view.accessibility.AccessibilityNodeInfoCompat.PANE_TITLE_KEY", charSequence);
            }
            this.a.d(view2, bVar);
            CharSequence text = accessibilityNodeInfo.getText();
            if (i < 26) {
                int i2;
                String str = "androidx.view.accessibility.AccessibilityNodeInfoCompat.SPANS_START_KEY";
                bVar.a.getExtras().remove(str);
                String str2 = "androidx.view.accessibility.AccessibilityNodeInfoCompat.SPANS_END_KEY";
                bVar.a.getExtras().remove(str2);
                String str3 = "androidx.view.accessibility.AccessibilityNodeInfoCompat.SPANS_FLAGS_KEY";
                bVar.a.getExtras().remove(str3);
                String str4 = "androidx.view.accessibility.AccessibilityNodeInfoCompat.SPANS_ID_KEY";
                bVar.a.getExtras().remove(str4);
                SparseArray sparseArray = (SparseArray) view2.getTag(2131297018);
                if (sparseArray != null) {
                    ArrayList arrayList = new ArrayList();
                    for (i2 = 0; i2 < sparseArray.size(); i2++) {
                        if (((WeakReference) sparseArray.valueAt(i2)).get() == null) {
                            arrayList.add(Integer.valueOf(i2));
                        }
                    }
                    for (i2 = 0; i2 < arrayList.size(); i2++) {
                        sparseArray.remove(((Integer) arrayList.get(i2)).intValue());
                    }
                }
                ClickableSpan[] d = b.d(text);
                if (d != null && d.length > 0) {
                    bVar.f().putInt("androidx.view.accessibility.AccessibilityNodeInfoCompat.SPANS_ACTION_ID_KEY", 2131296271);
                    SparseArray sparseArray2 = (SparseArray) view2.getTag(2131297018);
                    if (sparseArray2 == null) {
                        sparseArray2 = new SparseArray();
                        view2.setTag(2131297018, sparseArray2);
                    }
                    for (int i3 = 0; i3 < d.length; i3++) {
                        Object obj = d[i3];
                        for (int i4 = 0; i4 < sparseArray2.size(); i4++) {
                            if (obj.equals((ClickableSpan) ((WeakReference) sparseArray2.valueAt(i4)).get())) {
                                i2 = sparseArray2.keyAt(i4);
                                break;
                            }
                        }
                        i2 = b.d;
                        b.d = i2 + 1;
                        sparseArray2.put(i2, new WeakReference(d[i3]));
                        Object obj2 = d[i3];
                        Spanned spanned = (Spanned) text;
                        bVar.b(str).add(Integer.valueOf(spanned.getSpanStart(obj2)));
                        bVar.b(str2).add(Integer.valueOf(spanned.getSpanEnd(obj2)));
                        bVar.b(str3).add(Integer.valueOf(spanned.getSpanFlags(obj2)));
                        bVar.b(str4).add(Integer.valueOf(i2));
                    }
                }
            }
            List list = (List) view2.getTag(2131297017);
            if (list == null) {
                list = Collections.emptyList();
            }
            for (int i5 = 0; i5 < list.size(); i5++) {
                bVar.a((b.i.k.y.b.a) list.get(i5));
            }
        }

        public void onPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
            this.a.e(view, accessibilityEvent);
        }

        public boolean onRequestSendAccessibilityEvent(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
            return this.a.f(viewGroup, view, accessibilityEvent);
        }

        public boolean performAccessibilityAction(View view, int i, Bundle bundle) {
            return this.a.g(view, i, bundle);
        }

        public void sendAccessibilityEvent(View view, int i) {
            this.a.h(view, i);
        }

        public void sendAccessibilityEventUnchecked(View view, AccessibilityEvent accessibilityEvent) {
            this.a.i(view, accessibilityEvent);
        }
    }

    public a() {
        this.a = c;
        this.b = new a(this);
    }

    public boolean a(View view, AccessibilityEvent accessibilityEvent) {
        return this.a.dispatchPopulateAccessibilityEvent(view, accessibilityEvent);
    }

    public c b(View view) {
        AccessibilityNodeProvider accessibilityNodeProvider = this.a.getAccessibilityNodeProvider(view);
        return accessibilityNodeProvider != null ? new c(accessibilityNodeProvider) : null;
    }

    public void c(View view, AccessibilityEvent accessibilityEvent) {
        this.a.onInitializeAccessibilityEvent(view, accessibilityEvent);
    }

    public void d(View view, b bVar) {
        this.a.onInitializeAccessibilityNodeInfo(view, bVar.a);
    }

    public void e(View view, AccessibilityEvent accessibilityEvent) {
        this.a.onPopulateAccessibilityEvent(view, accessibilityEvent);
    }

    public boolean f(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
        return this.a.onRequestSendAccessibilityEvent(viewGroup, view, accessibilityEvent);
    }

    /* JADX WARNING: Removed duplicated region for block: B:29:0x0073  */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x0073  */
    /* JADX WARNING: Removed duplicated region for block: B:57:? A:{SYNTHETIC, RETURN, SKIP} */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x007b  */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x0073  */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x007b  */
    /* JADX WARNING: Removed duplicated region for block: B:57:? A:{SYNTHETIC, RETURN, SKIP} */
    public boolean g(android.view.View r9, int r10, android.os.Bundle r11) {
        /*
        r8 = this;
        r0 = 2131297017; // 0x7f0902f9 float:1.8211967E38 double:1.053000637E-314;
        r0 = r9.getTag(r0);
        r0 = (java.util.List) r0;
        if (r0 != 0) goto L_0x000f;
    L_0x000b:
        r0 = java.util.Collections.emptyList();
    L_0x000f:
        r1 = 0;
        r2 = 0;
    L_0x0011:
        r3 = r0.size();
        if (r2 >= r3) goto L_0x0070;
    L_0x0017:
        r3 = r0.get(r2);
        r3 = (b.i.k.y.b.a) r3;
        r4 = r3.a();
        if (r4 != r10) goto L_0x006d;
    L_0x0023:
        r0 = r3.d;
        if (r0 == 0) goto L_0x0070;
    L_0x0027:
        r0 = 0;
        r2 = r3.c;
        if (r2 == 0) goto L_0x0066;
    L_0x002c:
        r4 = new java.lang.Class[r1];	 Catch:{ Exception -> 0x0040 }
        r2 = r2.getDeclaredConstructor(r4);	 Catch:{ Exception -> 0x0040 }
        r4 = new java.lang.Object[r1];	 Catch:{ Exception -> 0x0040 }
        r2 = r2.newInstance(r4);	 Catch:{ Exception -> 0x0040 }
        r2 = (b.i.k.y.d.a) r2;	 Catch:{ Exception -> 0x0040 }
        java.util.Objects.requireNonNull(r2);	 Catch:{ Exception -> 0x003e }
        goto L_0x0065;
    L_0x003e:
        r0 = move-exception;
        goto L_0x0044;
    L_0x0040:
        r2 = move-exception;
        r7 = r2;
        r2 = r0;
        r0 = r7;
    L_0x0044:
        r4 = r3.c;
        if (r4 != 0) goto L_0x004b;
    L_0x0048:
        r4 = "null";
        goto L_0x004f;
    L_0x004b:
        r4 = r4.getName();
    L_0x004f:
        r5 = new java.lang.StringBuilder;
        r5.<init>();
        r6 = "Failed to execute command with argument class ViewCommandArgument: ";
        r5.append(r6);
        r5.append(r4);
        r4 = r5.toString();
        r5 = "A11yActionCompat";
        android.util.Log.e(r5, r4, r0);
    L_0x0065:
        r0 = r2;
    L_0x0066:
        r2 = r3.d;
        r0 = r2.a(r9, r0);
        goto L_0x0071;
    L_0x006d:
        r2 = r2 + 1;
        goto L_0x0011;
    L_0x0070:
        r0 = 0;
    L_0x0071:
        if (r0 != 0) goto L_0x0079;
    L_0x0073:
        r0 = r8.a;
        r0 = r0.performAccessibilityAction(r9, r10, r11);
    L_0x0079:
        if (r0 != 0) goto L_0x00ca;
    L_0x007b:
        r2 = 2131296271; // 0x7f09000f float:1.8210454E38 double:1.0530002686E-314;
        if (r10 != r2) goto L_0x00ca;
    L_0x0080:
        r10 = -1;
        r0 = "ACCESSIBILITY_CLICKABLE_SPAN_ID";
        r10 = r11.getInt(r0, r10);
        r11 = 2131297018; // 0x7f0902fa float:1.821197E38 double:1.0530006377E-314;
        r11 = r9.getTag(r11);
        r11 = (android.util.SparseArray) r11;
        r0 = 1;
        if (r11 == 0) goto L_0x00c9;
    L_0x0093:
        r10 = r11.get(r10);
        r10 = (java.lang.ref.WeakReference) r10;
        if (r10 == 0) goto L_0x00c9;
    L_0x009b:
        r10 = r10.get();
        r10 = (android.text.style.ClickableSpan) r10;
        if (r10 == 0) goto L_0x00c2;
    L_0x00a3:
        r11 = r9.createAccessibilityNodeInfo();
        r11 = r11.getText();
        r11 = b.i.k.y.b.d(r11);
        r2 = 0;
    L_0x00b0:
        if (r11 == 0) goto L_0x00c2;
    L_0x00b2:
        r3 = r11.length;
        if (r2 >= r3) goto L_0x00c2;
    L_0x00b5:
        r3 = r11[r2];
        r3 = r10.equals(r3);
        if (r3 == 0) goto L_0x00bf;
    L_0x00bd:
        r11 = 1;
        goto L_0x00c3;
    L_0x00bf:
        r2 = r2 + 1;
        goto L_0x00b0;
    L_0x00c2:
        r11 = 0;
    L_0x00c3:
        if (r11 == 0) goto L_0x00c9;
    L_0x00c5:
        r10.onClick(r9);
        r1 = 1;
    L_0x00c9:
        r0 = r1;
    L_0x00ca:
        return r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: b.i.k.a.g(android.view.View, int, android.os.Bundle):boolean");
    }

    public void h(View view, int i) {
        this.a.sendAccessibilityEvent(view, i);
    }

    public void i(View view, AccessibilityEvent accessibilityEvent) {
        this.a.sendAccessibilityEventUnchecked(view, accessibilityEvent);
    }

    public a(AccessibilityDelegate accessibilityDelegate) {
        this.a = accessibilityDelegate;
        this.b = new a(this);
    }
}
